﻿@{
    ViewBag.Title = "通知设置";
}

@section scripts
{
    <link rel="stylesheet" href="../Scripts/kindeditor-4.1.10/themes/default/default.css" />
    <script charset="utf-8" src="../Scripts/kindeditor-4.1.10/kindeditor-min.js"></script>
    <script charset="utf-8" src="../Scripts/kindeditor-4.1.10/lang/zh_CN.js"></script>
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script>
}
<div class="mini-toolbar" style="padding: 2px; border-top: 0; border-left: 0; border-right: 0;">
    <table style="width: 100%;">
        <tr>
            <td style="width: 100%;">
                <a class="mini-button" id="save" name="save" iconCls="icon-save" onclick="savePara" plain="true">保存</a>
                <span class="separator"></span>
                <a class="mini-button" iconCls="icon-close" onclick="CloseWindow" plain="true">关闭</a>
            </td>
        </tr>
    </table>
</div>
<form id="form1" runat="server" method="post" style="height:95%;" borderStyle="border:0;">
    <div id="layout1" class="mini-layout" style="width:100%;height:100%;" borderStyle="border:0;">
        <div region="center" showHeader = "false" >
            <div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;height:100%;" plain="false"  borderStyle="border:0;">
                <div title="参数设置">
                    <table>
                        <tr>
                            <td width="160px" height="30px"align="right">会员自动升级设置：</td>
                            <td>
                                <input id="FAutoUpgrade" name="FAutoUpgrade" class="mini-combobox" style="width:200px;" showNullItem="false"
                                    allowInput="false" align="left" value ="0" data ="dAutoUpgrade" onvaluechanged="giverule_changed"/> 
                            </td>
                        </tr>                                                  
                    </table> 
                </div>                
                <div title="赠送余额消费规则">
                    <table>
                        <tr>
                            <td width="160px" height="30px"align="right">会员赠送余额消费规则：</td>
                            <td>
                                <input id="FGiveRuleType" name="FGiveRuleType" class="mini-combobox" style="width:200px;" showNullItem="false"
                                    allowInput="false" align="left" value ="0" data ="dGiveRuleType" onvaluechanged="giverule_changed"/> 
                            </td>
                        </tr>   
                        <tr>
                            <td width="160px" height="30px" align="right">赠送消费比例(0~1)：</td>
                            <td>
                                <input id="FMultiple" name="FMultiple" class="mini-spinner " maxlength="10" style="width:200px;" minValue="0"
                                maxValue="1" TabIndex="11" showbutton="false" allowNull="true" changeOnMousewheel="false" format="#" />
                            </td>
                        </tr>                                                
                    </table>
                </div>
            </div>
        </div>
    </div>
</form>
<script>

    var dGiveRuleType = [{ "id": "0", "text": "不区分" },
                        { "id": "1", "text": "按本金对赠送消费比例" },
                        { "id": "2", "text": "先消费本金后消费赠送" }]

    var dAutoUpgrade = [{ "id": "0", "text": "不升级" },
                    { "id": "1", "text": "自动升级" }]

    mini.parse();
    var form = new mini.Form("form1");
    function FormShown() {
        mini.parse();
        getGiveRule();
    }

    function getGiveRule() {
        mini.get("save").setEnabled(true);
        $.post("GetSystemPara", { mSystemAppID: parent.window.getSystemAppID() }, function (data) {
            var form = new mini.Form("form1");
            var mdata = mini.decode(data);
            if (mdata.data.length > 0) {
                form.setData(mdata.data[0]);
                giverule_changed();
            }
        });
    }

    function savePara() {       
        var mjson = mini.encode(form.getData());
        mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '保存中, 请稍等......' });
        mini.get("save").setEnabled(false); 
        $.post("SaveSystemPara", { json: mjson, mSystemAppID: parent.window.getSystemAppID() }, function (data) {
            var ret = mini.decode(data);
            if (ret.status == 1) {
                mini.unmask(document.body);
                mini.showTips({ content: "保存成功。", state: "success", x: "center", y: "top", timeout: 3000 });
            }
            else {                
                mini.unmask(document.body);
                mini.alert("保存失败:" + ret.error);
            }
            mini.get("save").setEnabled(true); 
        });

    }

    function giverule_changed() {
        if (mini.get("FGiveRuleType").getValue() == "1") {
            mini.getbyName("FMultiple").setEnabled(true);            
        }
        else {
            mini.getbyName("FMultiple").setValue(0);
            mini.getbyName("FMultiple").setEnabled(false);
        }           
    }

</script>